import time

from Base.Base_jiuxian import Base
from selenium.webdriver.common.by import By
class Page(Base):
    login_loc=(By.CLASS_NAME,'headerLogin')
    # 断言登录页面
    login_dy_loc = (By.XPATH, '//*[@id="loginform"]/div/div/div/div/div[1]/div[1]/a[1]')
    # 输入用户名
    uname_loc = (By.ID, 'userName')
    # 输入用户名
    pwd_loc = (By.ID, 'password')
    # 强等
    # 点击登录
    login_btn_loc = (By.ID, 'save')
    # 断言登录成功
    success_loc = (By.XPATH, '/html/body/div[2]/div/div[1]/div/p/span')
    # 点击确定
    submit_loc = (By.ID, 'bindSub')

    def login(self):
        self.click(self.login_loc)

    # def login_dy(self):
    #     return self.click(self.login_dy_loc)

    def uname(self,username):
        # self.send_keys(self.uname_loc,'18986670716')
        self.find_element(self.uname_loc).send_keys(username)
    def pwd(self,password):
        # self.send_keys(self.pwd_loc,'Aa123456')
        self.find_element(self.pwd_loc).send_keys(password)

    def loginbtn(self):
        self.click(self.login_btn_loc)

    def success(self):
        return self.get_text(self.success_loc)

    def submit(self):
        self.click(self.submit_loc)

    def jiuxian_luoji(self,username,password):
        self.open_url('https://www.jiuxian.com/')
        self.login()
        # self.login_dy()
        self.uname(username)
        self.pwd(password)
        time.sleep(10)
        self.loginbtn()



        self.submit()
        self.success()

        print(self.success())
        assert 'jxw225264768' == self.success()
